FROM azul/zulu-openjdk-alpine:17-jre

# 设置环境变量
ENV CFG_ENABLED=true \
    CFG_NS=risk_dev \
    CFG_SVR=4a41f7c0-63e2-469a-996f-19203eb0f09f.nacos.cn-east-3.cse.myhuaweicloud.com:8848 \
    EXT_OPTS="-Dfile.encoding=UTF-8 -Dspring.config.location=classpath:/conf/" \
    JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom -Xms512m -Xmx1024m -Xss1024K -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m" \
    PORT=8080 \
    TZ=Asia/Shanghai \
    JAR_VERSION="event-gateway-1.0.0-SNAPSHOT.jar"

# 暴露端口
EXPOSE 8080 9779 8778

# 复制 Maven 构建的文件到容器
COPY target/$JAR_VERSION /maven/
RUN addgroup -g 3000 riskctr && \
    adduser --disabled-password -u 1000 -G riskctr riskctr && \
    chown -R 1000:3000 /maven/ && \
    chmod -R g=u /maven/

USER riskctr

# 设置入口点
ENTRYPOINT java $JAVA_OPTS $EXT_OPTS -Duser.timezone=$TZ \
           -Dspring.cloud.nacos.config.namespace=$CFG_NS \
           -Dspring.cloud.nacos.config.server-addr=$CFG_SVR \
           -Dspring.cloud.nacos.config.enabled=$CFG_ENABLED \
           -jar /maven/$JAR_VERSION
